/**
 * Created with JetBrains WebStorm.
 * User: Administrator
 * Date: 13-6-8
 * Time: 下午6:11
 * To change this template use File | Settings | File Templates.
 */

Ext.define('cloud.view.admin.Admin', {
    extend: 'Ext.navigation.View',
    xtype: 'admin',
    //requires: ['Ext.List', 'Ext.TitleBar', 'Ext.field.Select', 'Ext.field.Search'],
    config: {
        defaultBackButtonText: '返回',
        items: [
            {
                xtype: 'container',
                layout: 'hbox',
                title: '管理员管理',
                items: [
                    {
                        xtype: 'toolbar',
                        ui: 'dark',
                        docked: 'top',
                        items: [
                            {
                                xtype: 'textfield',
                                id: 'admin_search',
                                name: 'admin_search',
                                style: 'center',
                                placeHolder: '请输入管理员名称'
                            }
                        ]
                    },
                    {
                        xtype: 'list',
                        id: 'adminSelect',
                        flex: 1,
                        store: 'ManagerAppFindStore',
                        pressedCls: false,
                        selectedCls: false,
                        cls: 'x-list2',
                        onItemDisclosure: true,
                        emptyText: '还未添加管理员',
                        itemTpl: [
                            '<div class="listName">{name}</div>' +
                                '<div class="listConten">' +
                                '<span>所属应用:{appname}</span>  ' +
                                '<tpl if="status!=0">'+
                                    '<span>用户状态：已启用</span>' +
                                '<tpl else>'+
                                    '<span>用户状态：已停用</span>' +
                                '</tpl>'+
                                '</div> ' +
                                '<tpl if="camid!=localStorage.getItem(\'uid\')">'+
                                '<input type="button" id="restbutton" value="重置密码" name="restpassword" style="width: 80px; position: absolute; top: 30px; right: 60px;font-size: 12px;"  />'+'</tpl>'
                        ].join(''),
                        listeners: {
                            painted: function () {
                                var Store = Ext.getStore('ManagerAppFindStore');
                                Store.clearFilter();
                                Store.load({params: {caid: localStorage.getItem('caid')}});
                                Store.getProxy().setExtraParam('caid', localStorage.getItem('caid'));
                            }
                        },
                        plugins: [
                            {
                                xclass: 'Ext.plugin.PullRefresh',
                                pullRefreshText: '下拉可以更新',
                                releaseRefreshText: '松开开始更新',
                                style: 'top:12px',
                                loadingText: '正在刷新……',
                                refreshFn: function (loaded, arguments) {
                                   // loaded.getList().getStore().getProxy().setExtraParam('caid', localStorage.getItem('caid')); //设置proxy参数
                                    loaded.getList().getStore().loadPage(1, {
                                        callback: function (record, operation, success) {
                                            Ext.Viewport.unmask();
                                        }, scope: this });
                                }
                            },
                            {
                                xclass: 'Ext.plugin.ListPaging',
                                loadMoreText: '<h2 style="text-align: center; padding-top: 20px; padding-bottom: 20px;">点击加载更多。。。。</h2>',
                                noMoreRecordsText: '<h2 style="text-align: center; padding-top: 20px; padding-bottom: 20px;">没有更多条记录了</h2>',
                                autoPaging: false //设置为TRUE将自动触发
                            }
                        ]
                    },
                    {
                        xtype: 'toolbar',
                        id: 'admin_toolbar',
                        docked: 'bottom',
                        layout: {
                            type: 'hbox',
                            pack: 'center'
                        },
                        items: [
                            {
                                xtype: 'button',
                                id: 'admin_btn_add',
                                cls: 'x-button2',
                                iconMask: true,
                                text: '添加'
                            }
                        ]
                    }
                ]
            }
        ]
    }
});
